package stc.skymobi.fsm.test;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import xiaojian.toolkit.fsm.FSMContext;
import xiaojian.toolkit.fsm.FSMUtils;
import xiaojian.toolkit.fsm.FiniteStateMachine;
import xiaojian.toolkit.fsm.State;
import xiaojian.toolkit.fsm.annotation.StateDescription;


@StateDescription(name="unlock")
public class UnlockState implements State {

    private static final Logger logger = LoggerFactory.getLogger(UnlockState.class);
    
	public String acceptEvent(FiniteStateMachine fsm, FSMContext ctx, Object event) {
		logger.info("unlock state:" + event + ", id:" + ((Id)event).getId() );
		if ( event instanceof PassEvent ) {
			return	FSMUtils.getStateNameOfType(LockState.class);
		}
		return FSMUtils.getStateNameOfInstance(this);
	}

	/* (non-Javadoc)
	 * @see com.skymobi.fsm.State#enter(com.skymobi.fsm.FSMContext)
	 */
	public boolean enter(FiniteStateMachine fsm, FSMContext ctx) {
		System.out.println("enter unlock state");
		
		return	true;
	}

	/* (non-Javadoc)
	 * @see com.skymobi.fsm.State#leave(com.skymobi.fsm.FSMContext)
	 */
	public void leave(FiniteStateMachine fsm, FSMContext ctx) {
		System.out.println("leave unlock state");
	}

}
